package doan.tanduc;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
import doan.tanduc.R;

public class TasksScreen extends Activity implements Finish{
	private DataGetter datagetter;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.menu);
        
        final Button bt_capnhat = (Button) findViewById(R.id.bt_capnhattacvu);
        final Button bt_ex = (Button) findViewById(R.id.bt_ex);
		datagetter = new DataGetter(this, this);
		
        bt_ex.setOnClickListener(new OnClickListener(){
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent i = new Intent(TasksScreen.this, Manhinhchinh.class);
				startActivity(i);
			}        	
        }); 
        bt_capnhat.setOnClickListener(new OnClickListener(){
			public void onClick(View v) {
				// TODO Auto-generated method stub
		    	String link = "http://192.168.1.53/admin/tables/getinfor/"+Profile.sessionId;
		    	datagetter.execute(link);
			}        	
        }); 
        Bundle b = this.getIntent().getExtras();
        int areaPosition = b.getInt("areaPosition");
        int tablePosition = b.getInt("tablePosition");
        //get table
        Table table = Area.areasWithTables.get(areaPosition).getTable(tablePosition);
        // get all menu button
        Button bt_datdonhangmoi = (Button)findViewById(R.id.bt_datdonhangmoi);
        Button bt_chinhsuadonhang = (Button)findViewById(R.id.bt_chinhsuadonhang);
        Button bt_xemdonhang = (Button)findViewById(R.id.bt_xemdonhang);
        Button bt_huydonhang = (Button)findViewById(R.id.bt_huydonhang);
        // dat hang moi button
        if(!table.isUsed() || !table.isOrdered()){        	
        }
        else{
        	bt_datdonhangmoi.setEnabled(false);
        }
        // chinh sua don hang button, xem don hang
        if(table.isOrdered()){
        	// huy don hang
        	if(!table.isPrepared()){        		
        	}
        	else{
        		bt_huydonhang.setEnabled(false);
        	}
        }
        else{
        	bt_chinhsuadonhang.setEnabled(false);
        	bt_xemdonhang.setEnabled(false);
        	bt_huydonhang.setEnabled(false);
        }
        
        //Toast.makeText(this,b.getInt("tablePosition")+" "+b.getInt("areaPosition"), Toast.LENGTH_LONG).show();
        /*
        bt_xacnhan.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				// TODO Auto-generated method stub
				//Intent i = new Intent(TasksScreen.this, TasksScreen.class);
				//startActivity(i);
			}
		});
        bt_ex.setOnClickListener(new OnClickListener(){
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent i = new Intent(TasksScreen.this, Manhinhchinh.class);
				startActivity(i);
			}        	
        });  
        */  
    }
	public void doFinish() {
		// TODO Auto-generated method stub
		
	}   
}
